/*******************************************************************************
 * Copyright (c) 2012, 2013 XML-Print Project.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     XML-Print Project - initial API and implementation
 ******************************************************************************/
package info.xmlprint.ui.navigator;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.ContributionItem;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.navigator.CommonActionProvider;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;

public class PopueMenuConfig extends CommonActionProvider {

	// private WizardActionGroup newWizardActionGroup;
	private boolean contribute = false;

	@Override
	public void init(ICommonActionExtensionSite anExtensionSite) {

		if (anExtensionSite.getViewSite() instanceof ICommonViewerWorkbenchSite) {
			contribute = true;
		}
	}

	public void fillActionBars(IActionBars actionBars) {
		if (!contribute)
			return;


	}

	@Override
	public void fillContextMenu(IMenuManager menu) {
		//TODO: items of popumenu adaptiv activ/deactiv for folder content, fo,format and mapping 

		IStructuredSelection selection = (IStructuredSelection) getContext()
				.getSelection();
	//	boolean flag=false;
		if (selection.size() == 1) {
			Object obj = selection.getFirstElement();
			if (obj instanceof IFile || obj instanceof IProject) {
				//	flag=true;
			}
		}
		 

		for (IContributionItem ic : menu.getItems()) {
			ContributionItem cc=(ContributionItem) ic;
			//	
			//	System.out.println("ic: " + cc.getId()+cc.isSeparator()); 
		}
		menu.update(true);
	 

	}

}